package service.serviceImpl;

import dao.UserDao;
import entity.User;
import service.UserService;
import util.MyBatisUtils;

import java.util.HashMap;
import java.util.Map;

public class UserServiceImpl implements UserService {
    @Override
    public Map login(String userEmail, String password) {
        Map map = new HashMap();

        UserDao dao = MyBatisUtils.openSession().getMapper(UserDao.class);
        User user = dao.getUserByUserEmail(userEmail);
        if(user==null){
            map.put("isLogin",false);
            map.put("errMessage","用户名不存在");
        }else{
            if(user.getPassword().equals(password)){
                map.put("isLogin",true);
                map.put("user",user);
            }else{
                map.put("isLogin",false);
                map.put("errMessage","密码错误");
            }
        }

        return map;
    }
}
